<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/backstage/cl/common/wechatLibs.jsp"%>
<!doctype html>
<html>
<head>
    <title>购买颜值</title>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
</head>
<body>
<a href="/bsc/wechat/GomyBeauty">返回</a>
    <div class="buy-coin-box">
        <ul class="config">
           <c:forEach  var="beauty" items="${BBCList}" varStatus="status">
            <li dataid="${beauty.config_id}">
                <i class="ico" ><img src="/bsc/js/wechat/images/ico-coin1.png"></i>
                <div class="box">
                    <p class="fl"><span>${beauty.buy_num }币</span><span>赠送${beauty.give_num }个</span></p>
                    <p class="price fr">￥<fmt:formatNumber type="number"  value="${beauty.buy_num * 0.05 }" /></p>
                </div>
            </li>
            </c:forEach>
        </ul>
        <input id="config_id" type="hidden"/>
        <input id="shop_id" value="${shop_id }" type="hidden"/>
        <div class="btn"><a href="#" onclick="buyBeautyPay()">立即支付</a></div>
    </div>
</body>
<style>
 .config .active{
    background:#F00;
	border:#F00 1px solid;
 } 
</style>
<script type="text/javascript" src="/bsc/js/wechat/js/aui-dialog.js"></script>
<script src="/bsc/js/wechat/js/aui-pull-refresh.js"></script>
<script type="text/javascript">

$(function(){  
	$('.config li').click(function(){
	    $(this).addClass('active').siblings().removeClass('active');
	    $('#config_id').val($(this).attr('dataid'));
	})
 })
 //颜值支付
 function buyBeautyPay(){
	var toast = new auiToast();
	var dialog = new auiDialog({})
	  var config_id = $("#config_id").val();
		if (config_id== '') {
			toast.fail({
				title : "请选择你要购买的颜值",
				duration : 2000
			});
			return;
	 }
		 dialog.alert({
             title:"确认提示",
             msg:'真的要支付吗？',
             buttons:['支付 ','纯粹手滑']
         },function(ret){
        		toast.loading({
        			title : "订单正在取消中"

        		})
        		var shop_id= $("#shop_id").val();
       		 $.ajax({
       				type : 'post',
       				url : '/bsc/wechat/payment',
       				data : {
       					config_id:config_id
       				},
       				dataType : 'json',
       				success : function(data) {
       					if (data) {
       						if (data == "1") {
       							var token_id=data.token_id
       						    window.location.href = '/bsc/wechat/Gohome';
       						} else {
       							toast.fail({
       								title : data.appmsg,
       								duration : 2000
       							});
       						}
       					} else {
       						toast.fail({
       							title : "兑换失败，系统处理异常",
       							duration : 2000
       						});
       					}
       				},
       				error : function() {
       					toast.fail({
       						title : "网络异常",
       						duration : 2000
       					});
       				}
       			})
       			toast.hide();
         })
		
	
 }
 
</script>
</html>